<?php

/**
 * NoticeModel 模型
 * Class NoticeModel
 */
class NoticeModel extends BaseModel
{

    public $tableName = "notice";
    public $errMsg = '';

    static private $_singleton;

    public function __construct()
    {
        parent::__construct($this->tableName);
    }

    static public function getSingleton()
    {
        if (!self::$_singleton) {
            self::$_singleton = new static();
        }

        return self::$_singleton;
    }

    public function add($data)
    {
        try {
            $selfModel = static::getSingleton();
            return $selfModel->insert([
                'title'         => $data['title'],
                'content'       => $data['content'],
                'is_show'       => $data['is_show'],
                'create_time'   => time(),
                'create_user_id'    => $data['create_user_id'],
            ]);
        } catch (Exception $e) {
            $this->errMsg = $e->getMessage();
            return false;
        }
    }
}